from datetime import datetime
from pydantic import BaseModel, Field
from ..typings import QuestionType
from typing import Any, Literal, Optional


class Content(BaseModel):
    type: Literal["text", "image"]
    value: str


class Option(BaseModel):
    id: int = Field(alias="optionId")
    """选项id"""
    question_id: int = Field(alias="questionId")
    """题目id"""
    content: list[Content] = Field(alias="optionContent")
    """选项内容"""
    label: str = Field(alias="label")
    """选项标签"""


# class Question(BaseModel):
#     id: int = Field(alias="questionId")
#     """题目id"""
#     type: QuestionType = Field(alias="questionType")
#     """题目类型"""
#     title: list[Content] = Field(alias="title")
#     """题目标题"""
#     category: str = Field(alias="category")
#     """题目分类"""
#     score: int = Field(alias="score")
#     """题目分数"""
#     answer: list[Content] = Field(alias="answer")
#     """题目答案"""
#     options: list[Option] = Field(alias="options")

class UserAnswer(BaseModel, extra="ignore"):
    userExamId: str


class UserExam(BaseModel):
    userExamId: str
    userId: int
    examId: str
    startTime: datetime
    submitTime: Optional[datetime] = None
    totalScore: int
    status: str
    score: Optional[float] = None
    totalQuestions: int
    correctCount: Optional[int] = None
    totalTime: Optional[int] = None
    maxTime: Optional[int] = None
    passScore: int
    duration: int
    questions: Optional[Any] = None
